package cn.com.zonesion.rfiddemo.util;

import android.content.Context;
import android.content.pm.PackageManager;

public class APKVersionCodeUtils {
    /**
     * 获取当前本地apk的版本
     * @param mContext
     * @return
     */
    public static int getVersionCode(Context mContext){
        int versionCode = 0;

        try {
            //获取软件的版本号，对应AndroidManifest.xml下android:versionCode
            versionCode = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(),0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionCode;
    }
    public static String getVerName(Context context){
        String verName = "";
        try {
            verName = context.getPackageManager().getPackageInfo(context.getPackageName(),0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return verName;
    }
}
